package com.eastseeway.radioproject.entities;

import androidx.annotation.Keep;

import struct.StructClass;
import struct.StructField;
@Keep
@StructClass
public class BeanFromEnergyBoard {
    @StructField(order = 0)
    byte dstate;                 //联合体成员

    @StructField(order = 1)
    byte version;                         //版本信息

    @StructField(order = 2)
    byte version1;                         //版本信息

    @StructField(order = 3)
    byte selftestok;                      // 0：自检成功 其他：自检不正确，不同代码代表不同故障。

    @StructField(order = 4)
    byte IAP_update;

    @StructField(order = 5)
    byte temperature_A;                   // A相温度值（摄氏度）

    @StructField(order = 6)
    byte temperature_B;                   // B相温度值（摄氏度）

    @StructField(order = 7)
    byte temperature_C;                   // C相温度值（摄氏度）

    @StructField(order = 8)
    byte numofpackage;                         // 传输字节数

    @StructField(order = 9)
    byte sequenceofpackage;                    // 总线电压采样值（伏特）

    @StructField(order = 10)
    byte  nack;                    // 总线电流采样值（安培）


    public byte getDstate() {
        return dstate;
    }

    public void setDstate(byte dstate) {
        this.dstate = dstate;
    }

    public byte getVersion() {
        return version;
    }

    public void setVersion(byte version) {
        this.version = version;
    }

    public byte getVersion1() {
        return version1;
    }

    public void setVersion1(byte version1) {
        this.version1 = version1;
    }

    public byte getSelftestok() {
        return selftestok;
    }

    public void setSelftestok(byte selftestok) {
        this.selftestok = selftestok;
    }

    public byte getIAP_update() {
        return IAP_update;
    }

    public void setIAP_update(byte IAP_update) {
        this.IAP_update = IAP_update;
    }

    public byte getTemperature_A() {
        return temperature_A;
    }

    public void setTemperature_A(byte temperature_A) {
        this.temperature_A = temperature_A;
    }

    public byte getTemperature_B() {
        return temperature_B;
    }

    public void setTemperature_B(byte temperature_B) {
        this.temperature_B = temperature_B;
    }

    public byte getTemperature_C() {
        return temperature_C;
    }

    public void setTemperature_C(byte temperature_C) {
        this.temperature_C = temperature_C;
    }

    public byte getNumofpackage() {
        return numofpackage;
    }

    public void setNumofpackage(byte numofpackage) {
        this.numofpackage = numofpackage;
    }

    public byte getSequenceofpackage() {
        return sequenceofpackage;
    }

    public void setSequenceofpackage(byte sequenceofpackage) {
        this.sequenceofpackage = sequenceofpackage;
    }

    public byte getNack() {
        return nack;
    }

    public void setNack(byte nack) {
        this.nack = nack;
    }

    public boolean isReceiveOk(){
        int mask = 1;
        return (this.dstate & mask) == 1;
    }

    public boolean isOverVoltage(){
        int mask = 1 << 1;
        return (this.dstate & mask) != 0;
    }

    public boolean isOverCurrent(){
        int mask = 1 << 2;
        return (this.dstate & mask) != 0;
    }
}
